<template>
	<view class="login">
		<view class="avatar_box" style="top: 25vh;">
			<open-data class="avatar" type="userAvatarUrl" default-avatar="https://dev.stall.lkxlkf.com/ca/icons/default/default-icon.png"></open-data>
			<open-data class="nickname" type="userNickName"></open-data>
		</view>
		<button open-type="getUserInfo" style="background-color: #f7bb0e;color: #29282c;opacity: 0.7;" @getuserinfo="getuserinfo">微信授权</button>
	</view>
</template>

<script>
	export default {
		data() {
			return {

			}
		},
		methods: {
			getuserinfo(data) {
				console.log(data)
				this.$tool.getTokenValue({
					success: (data) => {
						console.log(data)
						uni.reLaunch({
							url: '../index/index'
						});
					}
				})

				// uni.authorize({
				// 	scope: 'scope.userInfo',
				// 	success: (data) => {
				// 		console.log(data)

				// 	},
				// 	fail(error) {
				// 		console.log(error)
				// 	}
				// })
				// this.$tool.getAuthorizeInfo('scope.userInfo', (res) => {
				// 	//已经授权，获取用户信息成功
				// 	uni.reLaunch({
				// 		url: '../index/index'
				// 	});
				// }, (res) => {
				// 	//没有授权，需要主动授权
				// 	console.log('未授权', res);
				// })
			}
		}
	}
</script>

<style lang="less">
	.login {
		height: 100vh;
		background-color: #29282c;
		display: flex;
		justify-content: center;
		align-items: center;

		.nickname {
			color: #FFFFFF;
		}
	}
</style>
